Skip to content

Add system table section along with profile events debugging#187

Open
VighneshPath wants to merge 1 commit into
mainfrom
add-system-table-profile-events-doc
Open

Add system table section along with profile events debugging#187
VighneshPath wants to merge 1 commit into
mainfrom
add-system-table-profile-events-doc

Conversation

@VighneshPath

Copy link
Copy Markdown

No description provided.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@VighneshPath

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@VighneshPath

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Jul 17, 2026
@VighneshPath
VighneshPath force-pushed the add-system-table-profile-events-doc branch from e49fab6 to 2754e61 Compare July 17, 2026 12:21

@filimonov filimonov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- clickhouse query performance
---

[`system.query_log`](https://clickhouse.com/docs/en/operations/system-tables/query_log) stores metadata and statistics about executed queries — start time, duration, error messages, resource usage, and other execution details. Its `ProfileEvents` column is where the per-query counters live, and it is the first place to look when a query is slower than expected.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most basic are duration and read_rows / read_bytes: usually enough to see queries where filtering does not work good.

Grouping by normalized query hash / initial_user / tables/ etc - is a common pattern.

For distributed - clusterAllReplicas query_log where initial_query_id = .... ordered by query_start_time_ms allow to see all the subqueries triggered by a single one (it can be very valuable).


Reading by `ValueType` is the trick that keeps the analysis honest: a `Bytes` counter tells you *how much data* moved, a `Microseconds` counter tells you *where the time went*, and you compare like with like. The most important accumulator is:

- **`RealTimeMicroseconds`** — total wall-clock time spent in processing threads. It is a **sum across threads**, so it can be much larger than the query's actual duration; every other `Microseconds` counter is a slice of it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple napkin math : divide it by click time to get how many cores were working

```json
{
"RealTimeMicroseconds": 9385304,
"OSCPUVirtualTimeMicroseconds": 2726569,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is one if the most important = how long cpu core were really working on that query (it's roughly the sum of user time and system time).

"UserTimeMicroseconds": 2604127,
"S3HeadObjectMicroseconds": 1022111,
"S3ReadMicroseconds": 1013884,
"OSCPUWaitMicroseconds": 925966,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can be the sign of cpu starvation. Especially if it is a significant % of cpu virtual time.

Similarly IOwait - is the clear sign of IO starvation

- Time in HEAD/GET requests to S3 (residual metadata only) → ~1 s
- Time a thread was ready to run but waiting → ~0.9 s
- Disk read from the cache → 65 ms
- Wait for Parquet reads from decoding threads → 62 ms

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Networkread / write microseconds can be very confusing sometimes. They just show how long one node was vaition for other to respond to subquery (it is not a network issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants